package com.punch.system.controller;


import com.punch.common.dto.system.SelectCourseDTO;
import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.query.syste.SelectCourseQueryInfo;
import com.punch.common.vo.system.SelectCourseVO;
import com.punch.system.service.SelectCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 精选课程表 前端控制器
 * </p>
 *
 * @author wjj
 * @since 2020-12-14
 */
@RestController
@Api(value = "SelectCourseController", tags = "精选课程管理Controller")
public class SelectCourseController {


    @Resource
    private SelectCourseService selectCourseService;

    /**
     * 精选课程列表
     *
     * @param queryInfo 查询条件
     * @return PageInfo<SelectCourseVO>
     */
    @GetMapping(value = "/select-courses", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "精选课程列表", notes = "精选课程列表", produces = "application/json")
    public Result<PageInfo<SelectCourseVO>> listSelectCourse(@ModelAttribute SelectCourseQueryInfo queryInfo) {
        return Result.succeed(selectCourseService.listSelectCourse(queryInfo));
    }


    /**
     * 保存精选课程
     *
     * @param selectCourseDTO 提交表单
     * @return id
     */
    @PostMapping(value = "/select-course", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 保存精选课程", notes = " 保存精选课程", produces = "application/json")
    public Result<Integer> saveSelectCourse(@RequestBody SelectCourseDTO selectCourseDTO) {
        return Result.succeed(selectCourseService.saveSelectCourse(selectCourseDTO));
    }

    /**
     * 修改精选课程
     *
     * @param selectCourseDTO 提交表单
     * @return id
     */
    @PutMapping(value = "/select-course", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改精选课程", notes = " 修改精选课程", produces = "application/json")
    public Result<Integer> updateSelectCourse(@RequestBody SelectCourseDTO selectCourseDTO) {
        return Result.succeed(selectCourseService.updateSelectCourse(selectCourseDTO));
    }


    /**
     * 精选课程详情
     *
     * @param selectCourseId selectCourseId
     * @return SelectCourseVO
     */
    @GetMapping(value = "/select-course/{selectCourseId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "精选课程详情", notes = "精选课程详情", produces = "application/json")
    public Result<SelectCourseVO> getSelectCourse(@PathVariable Integer selectCourseId) {
        return Result.succeed(selectCourseService.getSelectCourse(selectCourseId));
    }

    /**
     * 删除精选课程
     *
     * @param selectCourseId selectCourseId
     * @return id
     */
    @DeleteMapping(value = "/select-course/{selectCourseId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 删除精选课程", notes = " 删除精选课程", produces = "application/json")
    public Result<Integer> deleteSelectCourse(@PathVariable Integer selectCourseId) {
        return Result.succeed(selectCourseService.deleteSelectCourse(selectCourseId));
    }


    /**
     * 修改精选课程状态
     *
     * @param selectCourseId selectCourseId
     * @param status         状态 0-不显示 1-显示
     * @return selectCourseId
     */
    @PutMapping(value = "/select-course/{selectCourseId}/status/{status}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改精选课程状态", notes = " 修改精选课程状态", produces = "application/json")
    public Result<Integer> updateSelectCourseStatus(@PathVariable Integer selectCourseId, @PathVariable Integer status) {
        return Result.succeed(selectCourseService.updateSelectCourseStatus(selectCourseId, status));
    }

}
